//
//  HWZBAPIRequest.m
//  HWZB
//
//  Created by 许成雄 on 2017/4/29.
//  Copyright © 2017年 wonders. All rights reserved.
//

#import "HWZBAPIRequest.h"
#import "BaseAPIRequest.h"
#import <AFNetworking/AFNetworking.h>
#import "APIConfig.h"
#import "Context.h"

@interface HWZBAPIRequest()

@property (strong, nonatomic) AFHTTPRequestOperationManager *requestManager;

@end

@implementation HWZBAPIRequest

//UserAPIRequest单例方法
+ (instancetype)sharedInstance {
    
    static HWZBAPIRequest *instance = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        instance = [[self alloc] init];
    });
    return instance;
}

- (instancetype)init {
    if(self = [super init]) {
        self.requestManager = [AFHTTPRequestOperationManager manager];
    }
    return self;
}

#pragma mark - Public Method
//用户登录
- (void)userLoginWithParams:(NSDictionary *)params success:(void(^)(LoginResultInfo *))successHandler failure:(void(^)(NSError *))failureHandler {
    NSString *urlPath = [APIConfig userLoginURL];
    [[BaseAPIRequest sharedInstance] requestWithMethod:@"POST" URLPath:urlPath parameters:params success:^(id responseObject) {
        CommonInfo *resultInfo = [MTLJSONAdapter modelOfClass:[CommonInfo class] fromJSONDictionary:responseObject error:nil];
        if(resultInfo != nil) {
            if([resultInfo isSuccess]) {
                LoginResultInfo *result = [MTLJSONAdapter modelOfClass:[LoginResultInfo class] fromJSONDictionary:responseObject[@"data"] error:nil];
                successHandler(result);
            } else {
                NSDictionary *msg = @{NSLocalizedDescriptionKey: resultInfo.msg};
                NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
                failureHandler(error);
            }
        } else {
            NSDictionary *msg = @{NSLocalizedDescriptionKey: MSG_PARSE_DATA_FAILED};
            NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
            failureHandler(error);
        }
    } failure:^(NSError *error) {
        failureHandler(error);
    }];
}

//用户退出登录
- (void)userLogoutWithParams:(NSDictionary *)params success:(void(^)(CommonInfo *))successHandler failure:(void(^)(NSError *))failureHandler {
    NSString *loginId = [Context sharedInstance].loginID;
    if(loginId == nil) {
        NSDictionary *msg = @{NSLocalizedDescriptionKey: MSG_USER_NOT_LOGIN};
        NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
        failureHandler(error);
        return;
    }
    NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithCapacity:0];
    if(params != nil && params.count > 0) {
        [parameters addEntriesFromDictionary:params];
    }
    [parameters setObject:loginId forKey:@"loginid"];
    
    NSString *urlPath = [APIConfig userLogoutURL];
    [[BaseAPIRequest sharedInstance] requestWithMethod:@"POST" URLPath:urlPath parameters:params success:^(id responseObject) {
        CommonInfo *resultInfo = [MTLJSONAdapter modelOfClass:[CommonInfo class] fromJSONDictionary:responseObject error:nil];
        if(resultInfo != nil) {
            if([resultInfo isSuccess]) {
                successHandler(resultInfo);
            } else {
                NSDictionary *msg = @{NSLocalizedDescriptionKey: resultInfo.msg};
                NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
                failureHandler(error);
            }
        } else {
            NSDictionary *msg = @{NSLocalizedDescriptionKey: MSG_PARSE_DATA_FAILED};
            NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
            failureHandler(error);
        }
    } failure:^(NSError *error) {
        failureHandler(error);
    }];
}

//用户注册
- (void)userRegisterWithParams:(NSDictionary *)params success:(void(^)(RegisterResultInfo *))successHandler failure:(void(^)(NSError *))failureHandler {
    NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithCapacity:0];
    if(params != nil && params.count > 0) {
        [parameters addEntriesFromDictionary:params];
    }
    NSString *urlPath = [APIConfig userRegisterURL];
    [[BaseAPIRequest sharedInstance] requestWithMethod:@"POST" URLPath:urlPath parameters:parameters success:^(id responseObject) {
        CommonInfo *resultInfo = [MTLJSONAdapter modelOfClass:[CommonInfo class] fromJSONDictionary:responseObject error:nil];
        if(resultInfo != nil) {
            if([resultInfo isSuccess]) {
                RegisterResultInfo *registerResultInfo = [MTLJSONAdapter modelOfClass:[RegisterResultInfo class] fromJSONDictionary:responseObject[@"data"] error:nil];
                successHandler(registerResultInfo);
            } else {
                NSDictionary *msg = @{NSLocalizedDescriptionKey: resultInfo.msg};
                NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
                failureHandler(error);
            }
        } else {
            NSDictionary *msg = @{NSLocalizedDescriptionKey: MSG_PARSE_DATA_FAILED};
            NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
            failureHandler(error);
        }
    } failure:^(NSError *error) {
        failureHandler(error);
    }];
}

//获取注册验证码
- (void)getRegisterVerifyCodeWithParams:(NSDictionary *)params success:(void(^)(NSString *))successHandler failure:(void(^)(NSError *))failureHandler {
    NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithCapacity:0];
    if(params != nil && params.count > 0) {
        [parameters addEntriesFromDictionary:params];
    }
    NSString *urlPath = [APIConfig registerVerifyCodeURL];
    [[BaseAPIRequest sharedInstance] requestWithMethod:@"POST" URLPath:urlPath parameters:params success:^(id responseObject) {
        CommonInfo *resultInfo = [MTLJSONAdapter modelOfClass:[CommonInfo class] fromJSONDictionary:responseObject error:nil];
        if(resultInfo != nil) {
            if([resultInfo isSuccess]) {
                successHandler(resultInfo.msg);
            } else {
                NSDictionary *msg = @{NSLocalizedDescriptionKey: resultInfo.msg};
                NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
                failureHandler(error);
            }
        } else {
            NSDictionary *msg = @{NSLocalizedDescriptionKey: MSG_PARSE_DATA_FAILED};
            NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
            failureHandler(error);
        }
    } failure:^(NSError *error) {
        failureHandler(error);
    }];
}

//获取验证码
- (void)getVerifyCodeWithParams:(NSDictionary *)params success:(void(^)(NSString *))successHandler failure:(void(^)(NSError *))failureHandler {
    NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithCapacity:0];
    if(params != nil && params.count > 0) {
        [parameters addEntriesFromDictionary:params];
    }
    NSString *urlPath = [APIConfig verifyCodeURL];
    [[BaseAPIRequest sharedInstance] requestWithMethod:@"POST" URLPath:urlPath parameters:params success:^(id responseObject) {
        CommonInfo *resultInfo = [MTLJSONAdapter modelOfClass:[CommonInfo class] fromJSONDictionary:responseObject error:nil];
        if(resultInfo != nil) {
            if([resultInfo isSuccess]) {
                successHandler(resultInfo.msg);
            } else {
                NSDictionary *msg = @{NSLocalizedDescriptionKey: resultInfo.msg};
                NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
                failureHandler(error);
            }
        } else {
            NSDictionary *msg = @{NSLocalizedDescriptionKey: MSG_PARSE_DATA_FAILED};
            NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
            failureHandler(error);
        }
    } failure:^(NSError *error) {
        failureHandler(error);
    }];
}

//忘记密码
- (void)forgetPasswordWithParams:(NSDictionary *)params success:(void(^)(CommonInfo *))successHandler failure:(void(^)(NSError *))failureHandler {
    NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithCapacity:0];
    if(params != nil && params.count > 0) {
        [parameters addEntriesFromDictionary:params];
    }
    NSString *urlPath = [APIConfig forgetPasswordURL];
    [[BaseAPIRequest sharedInstance] requestWithMethod:@"POST" URLPath:urlPath parameters:parameters success:^(id responseObject) {
        CommonInfo *resultInfo = [MTLJSONAdapter modelOfClass:[CommonInfo class] fromJSONDictionary:responseObject error:nil];
        if(resultInfo != nil) {
            if([resultInfo isSuccess]) {
                successHandler(resultInfo);
            } else {
                NSDictionary *msg = @{NSLocalizedDescriptionKey: resultInfo.msg};
                NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
                failureHandler(error);
            }
        } else {
            NSDictionary *msg = @{NSLocalizedDescriptionKey: MSG_PARSE_DATA_FAILED};
            NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
            failureHandler(error);
        }
        
    } failure:^(NSError *error) {
        failureHandler(error);
    }];
}

//获取用户协议
- (void)getUserAgreementWithParams:(NSDictionary *)params success:(void(^)(NSString *))successHandler failure:(void(^)(NSError *))failureHandler {
    NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithCapacity:0];
    if(params != nil && params.count > 0) {
        [parameters addEntriesFromDictionary:params];
    }
    NSString *urlPath = [APIConfig userAgreementURL];
    [[BaseAPIRequest sharedInstance] requestWithMethod:@"POST" URLPath:urlPath parameters:parameters success:^(id responseObject) {
        CommonInfo *resultInfo = [MTLJSONAdapter modelOfClass:[CommonInfo class] fromJSONDictionary:responseObject error:nil];
        if(resultInfo != nil) {
            if([resultInfo isSuccess]) {
                NSDictionary *item = (NSDictionary *)[responseObject[@"data"] objectAtIndex:0];
                NSString *contentStr = [NSString stringWithFormat:@"%@", item[@"wxmpUrl"]];
                successHandler(contentStr);
            } else {
                NSDictionary *msg = @{NSLocalizedDescriptionKey: resultInfo.msg};
                NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
                failureHandler(error);
            }
        } else {
            NSDictionary *msg = @{NSLocalizedDescriptionKey: MSG_PARSE_DATA_FAILED};
            NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
            failureHandler(error);
        }
    } failure:^(NSError *error) {
        failureHandler(error);
    }];
}

//获取首页banner信息
- (void)getHomeBannerWithParams:(NSDictionary *)params success:(void(^)(NSArray *))successHandler failure:(void(^)(NSError *))failureHandler {
    NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithCapacity:0];
    if(params != nil && params.count > 0) {
        [parameters addEntriesFromDictionary:params];
    }
    NSString *urlPath = [APIConfig homeBannerURL];
    [[BaseAPIRequest sharedInstance] requestWithMethod:@"POST" URLPath:urlPath parameters:parameters success:^(id responseObject) {
        CommonInfo *resultInfo = [MTLJSONAdapter modelOfClass:[CommonInfo class] fromJSONDictionary:responseObject error:nil];
        if([resultInfo isSuccess]) {
            NSArray *bannerArray = [MTLJSONAdapter modelsOfClass:[HomeBannerInfo class] fromJSONArray:responseObject[@"data"] error:nil];
            successHandler(bannerArray);
        } else {
            NSDictionary *msg = @{NSLocalizedDescriptionKey: MSG_PARSE_DATA_FAILED};
            NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
            failureHandler(error);
        }
    } failure:^(NSError *error) {
        failureHandler(error);
    }];
}

//获取首页banner信息详情
- (void)getHomeBannerDetailWithParams:(NSDictionary *)params success:(void(^)(CommonInfo *))successHandler failure:(void(^)(NSError *))failureHandler{
    NSString *loginId = [Context sharedInstance].loginID;
    if(loginId == nil) {
        NSDictionary *msg = @{NSLocalizedDescriptionKey: MSG_USER_NOT_LOGIN};
        NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
        failureHandler(error);
        return;
    }
    NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithCapacity:0];
    if(params != nil && params.count > 0) {
        [parameters addEntriesFromDictionary:params];
    }
    NSString *urlPath = [APIConfig homeBannerDetailURL];
    [[BaseAPIRequest sharedInstance] requestWithMethod:@"POST" URLPath:urlPath parameters:parameters success:^(id responseObject) {
        CommonInfo *resultInfo = [MTLJSONAdapter modelOfClass:[CommonInfo class] fromJSONDictionary:responseObject error:nil];
        if(resultInfo != nil) {
            if([resultInfo isSuccess]) {
                successHandler(resultInfo);
            } else {
                NSDictionary *msg = @{NSLocalizedDescriptionKey: resultInfo.msg};
                NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
                failureHandler(error);
            }
        } else {
            NSDictionary *msg = @{NSLocalizedDescriptionKey: MSG_PARSE_DATA_FAILED};
            NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
            failureHandler(error);
        }
        
    } failure:^(NSError *error) {
        failureHandler(error);
    }];
}

//获取首页商品列表
- (void)getHomeCommoditiesWithParams:(NSDictionary *)params success:(void(^)(NSArray *))successHandler failure:(void(^)(NSError *))failureHandler{
    NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithCapacity:0];
    if(params != nil && params.count > 0) {
        [parameters addEntriesFromDictionary:params];
    }
    NSString *urlPath = [APIConfig homeCommoditiesURL];
    [[BaseAPIRequest sharedInstance] requestWithMethod:@"POST" URLPath:urlPath parameters:parameters success:^(id responseObject) {
        CommonInfo *resultInfo = [MTLJSONAdapter modelOfClass:[CommonInfo class] fromJSONDictionary:responseObject error:nil];
        if(resultInfo != nil) {
            if([resultInfo isSuccess]) {
                NSArray *commodityArray = [MTLJSONAdapter modelsOfClass:[CommodityInfo class] fromJSONArray:responseObject[@"data"][@"data"] error:nil];
                successHandler(commodityArray);
            } else {
                NSDictionary *msg = @{NSLocalizedDescriptionKey: resultInfo.msg};
                NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
                failureHandler(error);
            }
        } else {
            NSDictionary *msg = @{NSLocalizedDescriptionKey: MSG_PARSE_DATA_FAILED};
            NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
            failureHandler(error);
        }
    } failure:^(NSError *error) {
        failureHandler(error);
    }];
}


//获取商城商品列表
- (void)getCommoditiesWithParams:(NSDictionary *)params success:(void(^)(NSArray *))successHandler failure:(void(^)(NSError *))failureHandler{
    NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithCapacity:0];
    if(params != nil && params.count > 0) {
        [parameters addEntriesFromDictionary:params];
    }
    NSString *urlPath = [APIConfig commoditiesURL];
    [[BaseAPIRequest sharedInstance] requestWithMethod:@"POST" URLPath:urlPath parameters:parameters success:^(id responseObject) {
        CommonInfo *resultInfo = [MTLJSONAdapter modelOfClass:[CommonInfo class] fromJSONDictionary:responseObject error:nil];
        if(resultInfo != nil) {
            if([resultInfo isSuccess]) {
                NSArray *commodityArray = [MTLJSONAdapter modelsOfClass:[CommodityInfo class] fromJSONArray:responseObject[@"data"][@"data"] error:nil];
                successHandler(commodityArray);
            } else {
                NSDictionary *msg = @{NSLocalizedDescriptionKey: resultInfo.msg};
                NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
                failureHandler(error);
            }
        } else {
            NSDictionary *msg = @{NSLocalizedDescriptionKey: MSG_PARSE_DATA_FAILED};
            NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
            failureHandler(error);
        }
    } failure:^(NSError *error) {
        failureHandler(error);
    }];
}


//获取商城商品详情
- (void)getCommodityDetailWithParams:(NSDictionary *)params success:(void(^)(CommodityDetailInfo *))successHandler failure:(void(^)(NSError *))failureHandler{
    NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithCapacity:0];
    if(params != nil && params.count > 0) {
        [parameters addEntriesFromDictionary:params];
    }
    NSString *urlPath = [APIConfig commodityDetailURL];
    [[BaseAPIRequest sharedInstance] requestWithMethod:@"POST" URLPath:urlPath parameters:parameters success:^(id responseObject) {
        CommonInfo *resultInfo = [MTLJSONAdapter modelOfClass:[CommonInfo class] fromJSONDictionary:responseObject error:nil];
        if(resultInfo != nil) {
            if([resultInfo isSuccess]) {
                CommodityDetailInfo *detailInfo = [MTLJSONAdapter modelOfClass:[CommodityDetailInfo class] fromJSONDictionary:responseObject[@"data"] error:nil];
                successHandler(detailInfo);
            } else {
                NSDictionary *msg = @{NSLocalizedDescriptionKey: resultInfo.msg};
                NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
                failureHandler(error);
            }
        } else {
            NSDictionary *msg = @{NSLocalizedDescriptionKey: MSG_PARSE_DATA_FAILED};
            NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
            failureHandler(error);
        }
    } failure:^(NSError *error) {
        failureHandler(error);
    }];
}

//提交订单
- (void)commitOrderWithParams:(NSDictionary *)params success:(void(^)(OrderDetailInfo *))successHandler failure:(void(^)(NSError *))failureHandler{
    NSString *loginId = [Context sharedInstance].loginID;
    if(loginId == nil) {
        NSDictionary *msg = @{NSLocalizedDescriptionKey: MSG_USER_NOT_LOGIN};
        NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
        failureHandler(error);
        return;
    }
    NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithCapacity:0];
    if(params != nil && params.count > 0) {
        [parameters addEntriesFromDictionary:params];
    }
    [parameters setObject:loginId forKey:@"loginid"];
    NSString *urlPath = [APIConfig commitOrderURL];
    [[BaseAPIRequest sharedInstance] requestWithMethod:@"POST" URLPath:urlPath parameters:parameters success:^(id responseObject) {
        CommonInfo *resultInfo = [MTLJSONAdapter modelOfClass:[CommonInfo class] fromJSONDictionary:responseObject error:nil];
        if(resultInfo != nil) {
            if([resultInfo isSuccess]) {
                OrderDetailInfo *detailInfo = [MTLJSONAdapter modelOfClass:[OrderDetailInfo class] fromJSONDictionary:responseObject[@"data"] error:nil];
                successHandler(detailInfo);
            } else {
                NSDictionary *msg = @{NSLocalizedDescriptionKey: resultInfo.msg};
                NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
                failureHandler(error);
            }
        } else {
            NSDictionary *msg = @{NSLocalizedDescriptionKey: MSG_PARSE_DATA_FAILED};
            NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
            failureHandler(error);
        }
    } failure:^(NSError *error) {
        failureHandler(error);
    }];
}

//购买商品
- (void)payForOrderWithParams:(NSDictionary *)params success:(void(^)(NSString *))successHandler failure:(void(^)(NSError *))failureHandler{
    NSString *loginId = [Context sharedInstance].loginID;
    if(loginId == nil) {
        NSDictionary *msg = @{NSLocalizedDescriptionKey: MSG_USER_NOT_LOGIN};
        NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
        failureHandler(error);
        return;
    }
    NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithCapacity:0];
    if(params != nil && params.count > 0) {
        [parameters addEntriesFromDictionary:params];
    }
    [parameters setObject:loginId forKey:@"loginid"];
    NSString *urlPath = [APIConfig payURL];
    [[BaseAPIRequest sharedInstance] requestWithMethod:@"POST" URLPath:urlPath parameters:parameters success:^(id responseObject) {
        CommonInfo *resultInfo = [MTLJSONAdapter modelOfClass:[CommonInfo class] fromJSONDictionary:responseObject error:nil];
        if(resultInfo != nil) {
            if([resultInfo isSuccess]) {
                NSString *tempStr = [NSString stringWithFormat:@"%@", responseObject[@"data"]];
                successHandler(tempStr);
            } else {
                NSDictionary *msg = @{NSLocalizedDescriptionKey: resultInfo.msg};
                NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
                failureHandler(error);
            }
        } else {
            NSDictionary *msg = @{NSLocalizedDescriptionKey: MSG_PARSE_DATA_FAILED};
            NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
            failureHandler(error);
        }
    } failure:^(NSError *error) {
        failureHandler(error);
    }];
}

//我的订单
- (void)getMyOrdersWithParams:(NSDictionary *)params success:(void(^)(NSArray *))successHandler failure:(void(^)(NSError *))failureHandler{
    NSString *loginId = [Context sharedInstance].loginID;
    if(loginId == nil) {
        NSDictionary *msg = @{NSLocalizedDescriptionKey: MSG_USER_NOT_LOGIN};
        NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
        failureHandler(error);
        return;
    }
    NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithCapacity:0];
    if(params != nil && params.count > 0) {
        [parameters addEntriesFromDictionary:params];
    }
    [parameters setObject:loginId forKey:@"loginid"];
    
    NSString *urlPath = [APIConfig myOrdersURL];
    [[BaseAPIRequest sharedInstance] requestWithMethod:@"POST" URLPath:urlPath parameters:parameters success:^(id responseObject) {
        CommonInfo *resultInfo = [MTLJSONAdapter modelOfClass:[CommonInfo class] fromJSONDictionary:responseObject error:nil];
        if(resultInfo != nil) {
            if([resultInfo isSuccess]) {
                NSArray *orderArray = [MTLJSONAdapter modelsOfClass:[OrderInfo class] fromJSONArray:responseObject[@"data"][@"data"] error:nil];
                successHandler(orderArray);
            } else {
                NSDictionary *msg = @{NSLocalizedDescriptionKey: resultInfo.msg};
                NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
                failureHandler(error);
            }
        } else {
            NSDictionary *msg = @{NSLocalizedDescriptionKey: MSG_PARSE_DATA_FAILED};
            NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
            failureHandler(error);
        }
    } failure:^(NSError *error) {
        failureHandler(error);
    }];
}

//扫码邀请
- (void)getQRCodeInviteWithParams:(NSDictionary *)params success:(void(^)(InviteResultInfo *))successHandler failure:(void(^)(NSError *))failureHandler{
    NSString *loginId = [Context sharedInstance].loginID;
    if(loginId == nil) {
        NSDictionary *msg = @{NSLocalizedDescriptionKey: MSG_USER_NOT_LOGIN};
        NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
        failureHandler(error);
        return;
    }
    NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithCapacity:0];
    if(params != nil && params.count > 0) {
        [parameters addEntriesFromDictionary:params];
    }
    [parameters setObject:loginId forKey:@"id"];
    
    NSString *urlPath = [APIConfig qrCodeInviteURL];
    [[BaseAPIRequest sharedInstance] requestWithMethod:@"POST" URLPath:urlPath parameters:parameters success:^(id responseObject) {
        CommonInfo *resultInfo = [MTLJSONAdapter modelOfClass:[CommonInfo class] fromJSONDictionary:responseObject error:nil];
        if(resultInfo != nil) {
            if([resultInfo isSuccess]) {
                InviteResultInfo *inviteResultInfo = [MTLJSONAdapter modelOfClass:[InviteResultInfo class] fromJSONDictionary:responseObject[@"data"] error:nil];
                successHandler(inviteResultInfo);
            } else {
                NSDictionary *msg = @{NSLocalizedDescriptionKey: resultInfo.msg};
                NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
                failureHandler(error);
            }
        } else {
            NSDictionary *msg = @{NSLocalizedDescriptionKey: MSG_PARSE_DATA_FAILED};
            NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
            failureHandler(error);
        }
    } failure:^(NSError *error) {
        failureHandler(error);
    }];
}

//获取用户信息
- (void)getUserInfoWithParams:(NSDictionary *)params success:(void(^)(UserInfo *))successHandler failure:(void(^)(NSError *))failureHandler{
    NSString *loginId = [Context sharedInstance].loginID;
    if(loginId == nil) {
        NSDictionary *msg = @{NSLocalizedDescriptionKey: MSG_USER_NOT_LOGIN};
        NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
        failureHandler(error);
        return;
    }
    NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithCapacity:0];
    if(params != nil && params.count > 0) {
        [parameters addEntriesFromDictionary:params];
    }
    [parameters setObject:loginId forKey:@"loginid"];
    NSString *urlPath = [APIConfig userInfoURL];
    [[BaseAPIRequest sharedInstance] requestWithMethod:@"POST" URLPath:urlPath parameters:parameters success:^(id responseObject) {
        CommonInfo *resultInfo = [MTLJSONAdapter modelOfClass:[CommonInfo class] fromJSONDictionary:responseObject error:nil];
        if(resultInfo != nil) {
            if([resultInfo isSuccess]) {
                UserInfo *userInfo = [MTLJSONAdapter modelOfClass:[UserInfo class] fromJSONDictionary:responseObject[@"data"] error:nil];
                successHandler(userInfo);
            } else {
                NSDictionary *msg = @{NSLocalizedDescriptionKey: resultInfo.msg};
                NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
                failureHandler(error);
            }
        } else {
            NSDictionary *msg = @{NSLocalizedDescriptionKey: MSG_PARSE_DATA_FAILED};
            NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
            failureHandler(error);
        }
    } failure:^(NSError *error) {
        failureHandler(error);
    }];
}


//修改用户信息
- (void)modifyUserInfoWithParams:(NSDictionary *)params success:(void(^)(CommonInfo *))successHandler failure:(void(^)(NSError *))failureHandler{
    NSString *loginId = [Context sharedInstance].loginID;
    if(loginId == nil) {
        NSDictionary *msg = @{NSLocalizedDescriptionKey: MSG_USER_NOT_LOGIN};
        NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
        failureHandler(error);
        return;
    }
    NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithCapacity:0];
    if(params != nil && params.count > 0) {
        [parameters addEntriesFromDictionary:params];
    }
    [parameters setObject:loginId forKey:@"loginid"];
    
    NSString *urlPath = [APIConfig modifyUserInfoURL];
    [[BaseAPIRequest sharedInstance] requestWithMethod:@"POST" URLPath:urlPath parameters:parameters success:^(id responseObject) {
        CommonInfo *resultInfo = [MTLJSONAdapter modelOfClass:[CommonInfo class] fromJSONDictionary:responseObject error:nil];
        if(resultInfo != nil) {
            if([resultInfo isSuccess]) {
                successHandler(resultInfo);
            } else {
                NSDictionary *msg = @{NSLocalizedDescriptionKey: resultInfo.msg};
                NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
                failureHandler(error);
            }
        } else {
            NSDictionary *msg = @{NSLocalizedDescriptionKey: MSG_PARSE_DATA_FAILED};
            NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
            failureHandler(error);
        }
        
    } failure:^(NSError *error) {
        failureHandler(error);
    }];
}


//获取账户信息
- (void)getAccountInfoWithParams:(NSDictionary *)params success:(void(^)(AccountInfo *))successHandler failure:(void(^)(NSError *))failureHandler{
    NSString *loginId = [Context sharedInstance].loginID;
    if(loginId == nil) {
        NSDictionary *msg = @{NSLocalizedDescriptionKey: MSG_USER_NOT_LOGIN};
        NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
        failureHandler(error);
        return;
    }
    NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithCapacity:0];
    if(params != nil && params.count > 0) {
        [parameters addEntriesFromDictionary:params];
    }
    [parameters setObject:loginId forKey:@"loginid"];
    NSString *urlPath = [APIConfig accountInfoURL];
    [[BaseAPIRequest sharedInstance] requestWithMethod:@"POST" URLPath:urlPath parameters:parameters success:^(id responseObject) {
        CommonInfo *resultInfo = [MTLJSONAdapter modelOfClass:[CommonInfo class] fromJSONDictionary:responseObject error:nil];
        if(resultInfo != nil) {
            if([resultInfo isSuccess]) {
                AccountInfo *accountInfo = [MTLJSONAdapter modelOfClass:[AccountInfo class] fromJSONDictionary:responseObject[@"data"] error:nil];
                successHandler(accountInfo);
            } else {
                NSDictionary *msg = @{NSLocalizedDescriptionKey: resultInfo.msg};
                NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
                failureHandler(error);
            }
        } else {
            NSDictionary *msg = @{NSLocalizedDescriptionKey: MSG_PARSE_DATA_FAILED};
            NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
            failureHandler(error);
        }
    } failure:^(NSError *error) {
        failureHandler(error);
    }];
}


//获取团队信息
- (void)getMyTeamInfoWithParams:(NSDictionary *)params success:(void(^)(TeamInfo *))successHandler failure:(void(^)(NSError *))failureHandler {
    NSString *loginId = [Context sharedInstance].loginID;
    if(loginId == nil) {
        NSDictionary *msg = @{NSLocalizedDescriptionKey: MSG_USER_NOT_LOGIN};
        NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
        failureHandler(error);
        return;
    }
    NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithCapacity:0];
    if(params != nil && params.count > 0) {
        [parameters addEntriesFromDictionary:params];
    }
    [parameters setObject:loginId forKey:@"loginid"];
    NSString *urlPath = [APIConfig myTeamURL];
    [[BaseAPIRequest sharedInstance] requestWithMethod:@"POST" URLPath:urlPath parameters:parameters success:^(id responseObject) {
        CommonInfo *resultInfo = [MTLJSONAdapter modelOfClass:[CommonInfo class] fromJSONDictionary:responseObject error:nil];
        if(resultInfo != nil) {
            if([resultInfo isSuccess]) {
                TeamInfo *teamInfo = [MTLJSONAdapter modelOfClass:[TeamInfo class] fromJSONDictionary:responseObject[@"data"] error:nil];
                successHandler(teamInfo);
            } else {
                NSDictionary *msg = @{NSLocalizedDescriptionKey: resultInfo.msg};
                NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
                failureHandler(error);
            }
        } else {
            NSDictionary *msg = @{NSLocalizedDescriptionKey: MSG_PARSE_DATA_FAILED};
            NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
            failureHandler(error);
        }
    } failure:^(NSError *error) {
        failureHandler(error);
    }];
}

//提现
- (void)withdrawWithParams:(NSDictionary *)params success:(void(^)(CommonInfo *))successHandler failure:(void(^)(NSError *))failureHandler {
    NSString *loginId = [Context sharedInstance].loginID;
    if(loginId == nil) {
        NSDictionary *msg = @{NSLocalizedDescriptionKey: MSG_USER_NOT_LOGIN};
        NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
        failureHandler(error);
        return;
    }
    NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithCapacity:0];
    if(params != nil && params.count > 0) {
        [parameters addEntriesFromDictionary:params];
    }
    [parameters setObject:loginId forKey:@"loginid"];
    NSString *urlPath = [APIConfig withdrawURL];
    [[BaseAPIRequest sharedInstance] requestWithMethod:@"POST" URLPath:urlPath parameters:parameters success:^(id responseObject) {
        CommonInfo *resultInfo = [MTLJSONAdapter modelOfClass:[CommonInfo class] fromJSONDictionary:responseObject error:nil];
        if(resultInfo != nil) {
            if([resultInfo isSuccess]) {
                successHandler(resultInfo);
            } else {
                NSDictionary *msg = @{NSLocalizedDescriptionKey: resultInfo.msg};
                NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
                failureHandler(error);
            }
        } else {
            NSDictionary *msg = @{NSLocalizedDescriptionKey: MSG_PARSE_DATA_FAILED};
            NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
            failureHandler(error);
        }
    } failure:^(NSError *error) {
        failureHandler(error);
    }];
}


//获取提现记录
- (void)getWithdrawRecordsWithParams:(NSDictionary *)params success:(void(^)(NSArray *))successHandler failure:(void(^)(NSError *))failureHandler{
    NSString *loginId = [Context sharedInstance].loginID;
    if(loginId == nil) {
        NSDictionary *msg = @{NSLocalizedDescriptionKey: MSG_USER_NOT_LOGIN};
        NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
        failureHandler(error);
        return;
    }
    NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithCapacity:0];
    if(params != nil && params.count > 0) {
        [parameters addEntriesFromDictionary:params];
    }
    [parameters setObject:loginId forKey:@"loginid"];
    NSString *urlPath = [APIConfig withdrawRecordsURL];
    [[BaseAPIRequest sharedInstance] requestWithMethod:@"POST" URLPath:urlPath parameters:parameters success:^(id responseObject) {
        CommonInfo *resultInfo = [MTLJSONAdapter modelOfClass:[CommonInfo class] fromJSONDictionary:responseObject error:nil];
        if(resultInfo != nil) {
            if([resultInfo isSuccess]) {
                NSArray *recordArray = [MTLJSONAdapter modelsOfClass:[WithdrawRecordInfo class] fromJSONArray:responseObject[@"data"][@"data"] error:nil];
                successHandler(recordArray);
            } else {
                NSDictionary *msg = @{NSLocalizedDescriptionKey: resultInfo.msg};
                NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
                failureHandler(error);
            }
        } else {
            NSDictionary *msg = @{NSLocalizedDescriptionKey: MSG_PARSE_DATA_FAILED};
            NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
            failureHandler(error);
        }
    } failure:^(NSError *error) {
        failureHandler(error);
    }];
}


//获取我要领取信息
- (void)getIGetInfoWithParams:(NSDictionary *)params success:(void(^)(CommonInfo *))successHandler failure:(void(^)(NSError *))failureHandler{
    NSString *loginId = [Context sharedInstance].loginID;
    if(loginId == nil) {
        NSDictionary *msg = @{NSLocalizedDescriptionKey: MSG_USER_NOT_LOGIN};
        NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
        failureHandler(error);
        return;
    }
    NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithCapacity:0];
    if(params != nil && params.count > 0) {
        [parameters addEntriesFromDictionary:params];
    }
    [parameters setObject:loginId forKey:@"loginid"];
    NSString *urlPath = [APIConfig iGetURL];
    [[BaseAPIRequest sharedInstance] requestWithMethod:@"POST" URLPath:urlPath parameters:parameters success:^(id responseObject) {
        CommonInfo *resultInfo = [MTLJSONAdapter modelOfClass:[CommonInfo class] fromJSONDictionary:responseObject error:nil];
        if(resultInfo != nil) {
            if([resultInfo isSuccess]) {
                successHandler(resultInfo);
            } else {
                NSDictionary *msg = @{NSLocalizedDescriptionKey: resultInfo.msg};
                NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
                failureHandler(error);
            }
        } else {
            NSDictionary *msg = @{NSLocalizedDescriptionKey: MSG_PARSE_DATA_FAILED};
            NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
            failureHandler(error);
        }
    } failure:^(NSError *error) {
        failureHandler(error);
    }];
}


//修改密码
- (void)modifyPasswordWithParams:(NSDictionary *)params success:(void(^)(CommonInfo *))successHandler failure:(void(^)(NSError *))failureHandler{
    NSString *loginId = [Context sharedInstance].loginID;
    if(loginId == nil) {
        NSDictionary *msg = @{NSLocalizedDescriptionKey: MSG_USER_NOT_LOGIN};
        NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
        failureHandler(error);
        return;
    }
    NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithCapacity:0];
    if(params != nil && params.count > 0) {
        [parameters addEntriesFromDictionary:params];
    }
    [parameters setObject:loginId forKey:@"loginid"];
    NSString *urlPath = [APIConfig modifyPasswordURL];
    [[BaseAPIRequest sharedInstance] requestWithMethod:@"POST" URLPath:urlPath parameters:params success:^(id responseObject) {
        CommonInfo *resultInfo = [MTLJSONAdapter modelOfClass:[CommonInfo class] fromJSONDictionary:responseObject error:nil];
        if(resultInfo != nil) {
            if([resultInfo isSuccess]) {
                successHandler(resultInfo);
            } else {
                NSDictionary *msg = @{NSLocalizedDescriptionKey: resultInfo.msg};
                NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
                failureHandler(error);
            }
        } else {
            NSDictionary *msg = @{NSLocalizedDescriptionKey: MSG_PARSE_DATA_FAILED};
            NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
            failureHandler(error);
        }
    } failure:^(NSError *error) {
        failureHandler(error);
    }];
}


//版本更新
- (void)updateVersionWithParams:(NSDictionary *)params success:(void(^)(CommonInfo *))successHandler failure:(void(^)(NSError *))failureHandler{
    NSString *token = [Context sharedInstance].loginID;
    if(token == nil) {
        NSDictionary *msg = @{NSLocalizedDescriptionKey: MSG_USER_NOT_LOGIN};
        NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
        failureHandler(error);
        return;
    }
    NSString *urlPath = [APIConfig versionUpdateURL];
    [[BaseAPIRequest sharedInstance] requestWithMethod:@"POST" URLPath:urlPath parameters:params success:^(id responseObject) {
        CommonInfo *resultInfo = [MTLJSONAdapter modelOfClass:[CommonInfo class] fromJSONDictionary:responseObject error:nil];
        if(resultInfo != nil) {
            if([resultInfo isSuccess]) {
                successHandler(resultInfo);
            } else {
                NSDictionary *msg = @{NSLocalizedDescriptionKey: resultInfo.msg};
                NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
                failureHandler(error);
            }
        } else {
            NSDictionary *msg = @{NSLocalizedDescriptionKey: MSG_PARSE_DATA_FAILED};
            NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
            failureHandler(error);
        }
    } failure:^(NSError *error) {
        failureHandler(error);
    }];
}


//获取地址字典
- (void)getAddressDictWithParams:(NSDictionary *)params success:(void(^)(NSArray *))successHandler failure:(void(^)(NSError *))failureHandler{
    NSString *urlPath = [APIConfig addressURL];
    NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithCapacity:0];
    if(params != nil && params.count > 0) {
        [parameters addEntriesFromDictionary:params];
    }
    [[BaseAPIRequest sharedInstance] requestWithMethod:@"POST" URLPath:urlPath parameters:parameters success:^(id responseObject) {
        CommonInfo *resultInfo = [MTLJSONAdapter modelOfClass:[CommonInfo class] fromJSONDictionary:responseObject error:nil];
        if(resultInfo != nil) {
            if([resultInfo isSuccess]) {
                NSArray *addressArray = [MTLJSONAdapter modelsOfClass:[ProvinceInfo class] fromJSONArray:responseObject[@"data"] error:nil];
                successHandler(addressArray);
            } else {
                NSDictionary *msg = @{NSLocalizedDescriptionKey: resultInfo.msg};
                NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
                failureHandler(error);
            }
        } else {
            NSDictionary *msg = @{NSLocalizedDescriptionKey: MSG_PARSE_DATA_FAILED};
            NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
            failureHandler(error);
        }
    } failure:^(NSError *error) {
        failureHandler(error);
    }];
}

//获取银行字典
- (void)getBankDictWithParams:(NSDictionary *)params success:(void(^)(NSArray *))successHandler failure:(void(^)(NSError *))failureHandler {
    NSString *urlPath = [APIConfig bankTypeURL];
    NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithCapacity:0];
    if(params != nil && params.count > 0) {
        [parameters addEntriesFromDictionary:params];
    }
    [[BaseAPIRequest sharedInstance] requestWithMethod:@"POST" URLPath:urlPath parameters:parameters success:^(id responseObject) {
        CommonInfo *resultInfo = [MTLJSONAdapter modelOfClass:[CommonInfo class] fromJSONDictionary:responseObject error:nil];
        if(resultInfo != nil) {
            if([resultInfo isSuccess]) {
                NSArray *addressArray = [MTLJSONAdapter modelsOfClass:[BankInfo class] fromJSONArray:responseObject[@"data"] error:nil];
                successHandler(addressArray);
            } else {
                NSDictionary *msg = @{NSLocalizedDescriptionKey: resultInfo.msg};
                NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
                failureHandler(error);
            }
        } else {
            NSDictionary *msg = @{NSLocalizedDescriptionKey: MSG_PARSE_DATA_FAILED};
            NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
            failureHandler(error);
        }
    } failure:^(NSError *error) {
        failureHandler(error);
    }];
}

//获取商品类型字典
- (void)getCommodityTypeDictWithParams:(NSDictionary *)params success:(void(^)(NSArray *))successHandler failure:(void(^)(NSError *))failureHandler {
    NSString *urlPath = [APIConfig commodityTypeURL];
    NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithCapacity:0];
    if(params != nil && params.count > 0) {
        [parameters addEntriesFromDictionary:params];
    }
    [[BaseAPIRequest sharedInstance] requestWithMethod:@"POST" URLPath:urlPath parameters:parameters success:^(id responseObject) {
        CommonInfo *resultInfo = [MTLJSONAdapter modelOfClass:[CommonInfo class] fromJSONDictionary:responseObject error:nil];
        if(resultInfo != nil) {
            if([resultInfo isSuccess]) {
                NSArray *addressArray = [MTLJSONAdapter modelsOfClass:[CommodityTypeInfo class] fromJSONArray:responseObject[@"data"] error:nil];
                successHandler(addressArray);
            } else {
                NSDictionary *msg = @{NSLocalizedDescriptionKey: resultInfo.msg};
                NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
                failureHandler(error);
            }
        } else {
            NSDictionary *msg = @{NSLocalizedDescriptionKey: MSG_PARSE_DATA_FAILED};
            NSError *error = [NSError errorWithDomain:HWZBErrorDomain code:(HWZB_ERROR_CODE) userInfo:msg];
            failureHandler(error);
        }
    } failure:^(NSError *error) {
        failureHandler(error);
    }];
}

@end
